package Java_object0823;

public class Elevator {
    public int currentFloor;
    public int destinationFloor;
    public boolean up;
    public boolean doorsOpen;

    public void openDoors(boolean doorsOpen){
        if (this.doorsOpen) {
            System.out.println("正在开门");
        } else {
            System.out.println("正在关门");
        }
    }

    public void goingUp(){
       this.up = true;
        System.out.println("电梯正在上行");
    }

    public void goingDown(){
        this.up = false;
        System.out.println("电梯正在下降");
    }

    public void goToFloor(int x){
        System.out.println("你要去"+x+"层");
        this.doorsOpen = false;
        this.openDoors(this.doorsOpen);

        if (x>this.currentFloor){
            this.goingUp();
        }else if (x<this.currentFloor){
            this.goingDown();
        }

        System.out.println("到达目标楼层");
        this.doorsOpen = true;
        this.openDoors(this.doorsOpen);
        this.currentFloor = x;
    }

}
